//
//  TableViewModel+LabelRows.swift
//  CooperSwift
//
//  Created by 计海峰 on 2022/1/17.
//

import Foundation

// 通用 rows 的一些扩展
public extension TableViewModelProtocol {
    
    //MARK: -  label cell
    func lbRow(_ text: String = "", color: UIColor = .darkGray, bgColor: UIColor? = nil, font: UIFont = .systemFont(ofSize: 15), lines: Int = 1, padding: UIEdgeInsets? = nil, textAlignment: NSTextAlignment? = nil, key: String? = nil, isTarget: Bool = true) -> TableShowLabelCellModel {
        let lbConfig = TableShowBaseControlConfig().then {
            $0.font = font
            $0.textColor = color
            if let color = bgColor {
                $0.bgColor = color
            }
            $0.text = text
            $0.lines = lines
            $0.textAlignment = textAlignment
            if let lbPadding = padding {
                $0.padding = lbPadding
            }
        }
        let lbCellModel =  TableShowLabelCellModel(lbConfig).then {
            if let bindKey = key {
                $0.addTargetKey(bindKey, isTarget: isTarget)
            }
        }
        return lbCellModel
    }
    
}
